package com.ForeHome.app.Service.Impl;

import com.ForeHome.app.Mapper.ProductMapper;
import com.ForeHome.app.Service.ProductService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tamll.bean.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;

    @Override
    public List<Product> title_category_id(Integer categoryId) {
        QueryWrapper<Product> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("product_category_id",categoryId);
        return productMapper.selectList(queryWrapper);
    }

    @Override
    public List<Product> listImage() {
        QueryWrapper<Product> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("product_isEnabled",2);
        return productMapper.selectList(queryWrapper);
    }


    /**
     * 根据商品id查询商品
     * @param product_id 商品id
     * @return 返回查询结果
     */
    @Override
    public Product selectProductId(Integer product_id) {
        QueryWrapper<Product> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("product_id",product_id);
        return productMapper.selectOne(queryWrapper);
    }


}
